package com.slz3.business.module.goodsManagement.gooTypeLevel2.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.frame.util.VE;
import com.slz3.business.module.goodsManagement.gooTypeLevel2.domain.GooTypeLevel2;
import com.slz3.business.module.goodsManagement.gooTypeLevel2.domain.GooTypeLevel2Condition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.util.UUID;

@Controller
public class GooTypeLevel2ResController {

    @Autowired
    private GooTypeLevel2ResAtomic gooTypeLevel2ResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, GooTypeLevel2 gooTypeLevel2) {
        if (GooTypeLevel2ResUnsafeValid.add(req, gooTypeLevel2)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            UUID serOneId = gooTypeLevel2.getSerOneId();
            if(VE.isEmpty(serOneId)){
                return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
            }
            return gooTypeLevel2ResAtomic.add_$GooTypeLevel2UpdateLock(req, gooTypeLevel2);
        }
    }

    public  Mono<ServerResponse> delete(ServerRequest req, GooTypeLevel2Condition gooTypeLevel2Condition) {
        if (GooTypeLevel2ResUnsafeValid.delete(req, gooTypeLevel2Condition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.delete_$GooTypeLevel2UpdateLock(req, gooTypeLevel2Condition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, GooTypeLevel2 gooTypeLevel2) {
        if (GooTypeLevel2ResUnsafeValid.modify(req, gooTypeLevel2)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.modify_$GooTypeLevel2UpdateLock(req, gooTypeLevel2);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (GooTypeLevel2ResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return GooTypeLevel2ResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
        if (GooTypeLevel2ResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.info_$GooTypeLevel2UpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (GooTypeLevel2ResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return GooTypeLevel2ResExecutor.choice(req);
        }
    }

    public final Mono<ServerResponse> auditSubmit(ServerRequest req, GooTypeLevel2Condition gooTypeLevel2Condition) {
        //
        if (GooTypeLevel2ResUnsafeValid.auditSubmit(req, gooTypeLevel2Condition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.auditSubmit_$GooTypeLevel2UpdateLock(req, gooTypeLevel2Condition);
        }
    }

    public final Mono<ServerResponse> audit(ServerRequest req, GooTypeLevel2Condition gooTypeLevel2Condition) {
        if (GooTypeLevel2ResUnsafeValid.audit(req, gooTypeLevel2Condition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.audit_$GooTypeLevel2UpdateLock(req, gooTypeLevel2Condition);
        }
    }

    public final Mono<ServerResponse> auditReject(ServerRequest req, GooTypeLevel2Condition gooTypeLevel2Condition) {
        if (GooTypeLevel2ResUnsafeValid.auditReject(req, gooTypeLevel2Condition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.auditReject_$GooTypeLevel2UpdateLock(req, gooTypeLevel2Condition);
        }
    }

    public final Mono<ServerResponse> usingEnable(ServerRequest req, GooTypeLevel2Condition gooTypeLevel2Condition) {
        if (GooTypeLevel2ResUnsafeValid.usingEnable(req, gooTypeLevel2Condition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.usingEnable_$GooTypeLevel2UpdateLock(req, gooTypeLevel2Condition);
        }
    }

    public final Mono<ServerResponse> usingDisable(ServerRequest req, GooTypeLevel2Condition gooTypeLevel2Condition) {
        if (GooTypeLevel2ResUnsafeValid.usingDisable(req, gooTypeLevel2Condition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return gooTypeLevel2ResAtomic.usingDisable_$GooTypeLevel2UpdateLock(req, gooTypeLevel2Condition);
        }
    }

}
